/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package networktrain;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author benjamin
 */



public class Client extends Thread {
    
public int LocalPort;
public int DestPort;
public Recieve reciever; 
public ServerSocket ss;


public Client(int LocalPort,int DestPort) throws IOException{
    this.LocalPort=LocalPort;
    this.DestPort=DestPort;
    this.ss=new ServerSocket(LocalPort);

    
}

public void run(){
    Socket tempSock;
    while(true){
            try {
                tempSock=ss.accept();
                //Accept a connection and give the relay to a newly created threaded reciever.
                System.out.println("Connection accepted");
                new Recieve(tempSock).start();
                                
            } catch (IOException ex) {
                Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);
            }
    }
}

}
